<%--
  Created by IntelliJ IDEA.
  User: 骆鹏
  Date: 2017/8/14
  Time: 17:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<html>
<head>
    <title><fmt:message code="workflow.th.defineprocess" /></title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="../lib/layui/layui/css/layui.css" media="all">

    <script src="/lib/jQuery-File-Upload-master/jquery-1.8.3.min.js"></script>
    <script src="/lib/layer/layer.js?20201106"></script>
    <script src="/js/base/base.js"></script>
    <script src="/lib/ueditor/ueditor.config.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/ueditor/ueditor.all.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jquery.form.min.js"></script>
    <script src="/lib/laydate/laydate.js"></script>
    <script src="/lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.ui.widget.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.iframe-transport.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.fileupload.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="/js/common/fileupload.js"></script>
    <link rel="stylesheet" href="/css/workflow/work/attributeTwo.css?20190516">
    <style>
        .form_group input[type='radio']{
            padding-right: 0;
        }
        .form_group label.flowName{
            width: 23%;
        }
        .conForm_r{
            left: 710px;
        }
        .fujianOut{
            margin-bottom: 8px;
        }
        .img_{
            margin-top: -5px;
            margin-right: 5px;
        }
        .div {
            display: inline-block;
            padding: 0;
            position: relative;
        }

        .div input {
            width: 400px;
            height: 30px;
            line-height: 30px;
            font: 14px arial;
            color: #333;
            border: 1px solid #b8b8b8;
            padding: 2px 0px 2px 8px;
            border-radius: 5px;
        }

        #search-button {
            position: absolute;
            height: 23px;
            width: 29px;
            top: -2px;
            right: -6px;
            cursor: pointer;
        }

        .search-img {
            position: absolute;
            height: 0px;
            width: 0px;
            top: 13px;
            right: 10px;
            overflow: hidden;
            cursor: pointer;
            border-width: 5px;
            border-style: solid dashed dashed;
            border-color: #000 transparent transparent;
            background-repeat: no-repeat;
            opacity: .6;
        }

        .div span.up {
            border-width: 5px;
            border-style: dashed dashed solid;
            border-color: transparent transparent #000;
            top: 7px;
        }

        .div select {
            width:287px;
            height: 200px;
            margin: 0px;
            padding: 2px 0px;
            outline: none;
            border: 1px solid #b8b8b8;
            position: absolute;
            top: 35px;
            left: 0;
            box-shadow: 0 0 16px 0 rgba(53,53,53,.2);
        }

        .div select option {
            height: 18px;
            line-height: 18px;
            cursor: default;
            font: 14px arial;
            padding: 2px 8px;
        }

        .div select option:hover {
            background: #f0f0f0;
        }
    </style>
    <script>
        /*function uploadinputimg(me) {

            $('#uploadimgform').attr('action','/flow/fileUpload?module=workflow');
//            $('#uploadimgform')[0].attributes['action'].value='http://localhost:8080/flow/fileUpload?module=workflow'
            $('#uploadimgform').ajaxSubmit({
                type:'post',
                dataType:'html',
                success:function (jsons) {
                    var json=JSON.parse(jsons)
                    var attachNameHtml=''
                    var arrOne=json.datas;
                    for(var i=0;i<arrOne.length;i++){
                        /!*if(i!=arrOne.length-1) {
                            attachId += arrOne[i].attStrId + ',';
                            attachName+=arrOne[i].attStrName+'*';
                        }else {
                            attachId += arrOne[i].attStrId;
                            attachName+=arrOne[i].attStrName;
                        }*!/
                        attachNameHtml+='<div class="fujianOut"><a class="fujian" deUrl="'+arrOne[0].attUrl+'" attachId="'+arrOne[0].attStrId+','+'" attachName="'+arrOne[0].attStrName+'*'+'" style="width: 20%;margin-bottom:10px;vertical-align:bottom;margin-right: 10px;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;color: #54b6fe;" href="/download?'+arrOne[i].attUrl+'" class="fileAA" title="'+arrOne[i].attachName+'"><img class="img_" src="../img/enclosure.png">'+arrOne[i].attachName+'<span style="margin-left: 5px;">('+arrOne[i].size+')</span></a><img class="deImgs" style="margin-left:5px;cursor: pointer;" src="../img/file/icon_deletecha_03.png"/><input type="hidden" class="inHidden" value=""></div>'
                    }
                    $('.notable').append(attachNameHtml)
                }
            })
        }*/
    </script>
</head>
<body style="height: 100%;">

<div class="define_r clearfix">
    <img style="width: 18px;padding-left: 15px;float: left;margin-top: 12px;" src="/img/workflow/flowsetting/flowSettingMain/shejiliucheng.png"  alt="">
    <label style="float: left;padding-left: 10px;font-weight: bold"><fmt:message code="workflow.th.defineprocess" /></label>
    <span style="float: right"><a href="javascript:void(0)" class="keepmsg"><fmt:message code="global.lang.save" /></a></span>
</div>




<form id="uploadimgform" target="uploadiframe" action="" enctype="multipart/form-data" method="post" style="height: 100%;overflow-y: auto;display: none">
    <div class="cont_r" style="margin-left: 0px;margin-top: 48px;">
        <input type="hidden" name="attachmentId">
        <input type="hidden" name="attachmentName">
        <input type="hidden" name="flowDesc">
        <input type="hidden" name="flowId">
        <input type="hidden" name="formId">
        <div class="over_f  con_flow" style="border: none;">
            <p class="define_p"><fmt:message code="workflow.th.basicattributes" /></p>
            <div class="con_form">
                <div class="form_group">
                    <label class="flowName"><fmt:message code="workflow.th.processname" /> <span>*</span></label>
                    <input type="text" name="flowName" id="projectName">
                </div>
                <div class="form_group">
                    <label class="flowName"><fmt:message code="workflow.th.process" /> <span>*</span></label>
                    <select name="flowSort" id="classfiy" class="depName">
                        <option value=""><fmt:message code="hr.th.PleaseSelect" /></option>
                    </select>
                </div>
                <div class="form_group">
                    <label class="flowName"><fmt:message code="workflow.th.flowtype" /> <span>*</span></label>
                    <select name="flowType" id="class_f" class="depName">
                        <option value="1"><fmt:message code="workflow.th.fixedflow" /></option>
                        <%--<option value="2"><fmt:message code="workflow.th.freeflow" /></option>--%>
                    </select>
                </div>
                <div class="form_group">
                    <label class="flowName"><fmt:message code="workfolw.th.form" /> <span>*</span></label>
                    <%--<select name="formId" id="leave" class="depName">--%>
                    <%--<option value=""><fmt:message code="hr.th.PleaseSelect" /></option>--%>
                    <%--</select>--%>
                    <div class="div">
                        <input type="text" id="makeupCo" class="makeinp" onfocus='setfocus(this,"#typenum","#makeupCo","#search-button")' oninput='setinput(this,"#typenum");' placeholder="请选择或输入匹配文字" />
                        <div id="search-button" onclick='setfocus(document.getElementById("makeupCo"),"#typenum","#makeupCo","#search-button")'>
                            <span class="search-img"></span></div>
                        <select name="formId" id="typenum" onchange='changeF(this,"#typenum","makeupCo","#search-button")' size="10" style="display:none;">

                        </select>
                    </div>
                </div>
                <div class="form_group">
                    <label class="flowName"><fmt:message code="workflow.th.delegatetype" /> <span>*</span></label>
                    <select name="freeOther" id="delegate-type" class="depName">
                        <option value="2"><fmt:message code="workflow.th.freecommission" /></option>
                        <option value="1"><fmt:message code="workflow.th.handlers" /></option>
                        <option value="3"><fmt:message code="workflow.th.permissions" /></option>
                        <option value="0"><fmt:message code="workflow.th.nodelegation" /></option>
                    </select>
                </div>
                <div class="form_group">
                    <label class="flowName"><fmt:message code="workflow.th.sector" /> <span>*</span></label>
                    <select name="deptId" id="deptName" class="depName">
                        <option value=""><fmt:message code="hr.th.PleaseSelect" /></option>
                    </select>
                </div>
                <div class="form_group">
                    <label class="flowName"><fmt:message code="workflow.th.sortnumber" /> </label>
                    <input type="text" name="flowNo" id="orderID" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}">
                </div>
                <div class="form_group sex_r">
                    <label class="flowName"><fmt:message code="workflow.th.circulate" /></label>
                    <input type="radio" name="viewPriv" value="1" class="radio_s" checked="checked">
                    <label class="sex_n" ><fmt:message code="global.lang.yes" /></label>
                    <input type="radio" name="viewPriv" value="0" class="radio_s" checked="checked">
                    <label class="sex_save"><fmt:message code="global.lang.no" /></label>
                </div>
                <div class="form_group block_n" style="padding-left: 24%;display: none">
                    <div class="title_3" style="margin-top: 0;">
                        <div class="title3_label">
                            <span class="title_s"><fmt:message code="workflow.th.chuan" /></span></div>
                        <div class="select_put">
                            <textarea name="txt" id="text_1" user_id="" value="" disabled=""></textarea>
                            <a style="margin-left: 10px;cursor: pointer;color: #3994f7;" id="add_f_1"><fmt:message code="global.lang.add" /></a><a class="clearAll" style="    color: #3994f7;"><fmt:message code="global.lang.empty" /></a></div>
                        <input type="hidden" name="viewUser" value="">
                        <input type="hidden" name="viewUserName">
                    </div>
                    <div class="title_3">
                        <div class="title3_label">
                            <span class="title_s"><fmt:message code="workflow.th.chuanyueren" /></span></div>
                        <div class="select_put">
                            <textarea name="txt" id="text_2" value="" disabled="" deptid=""></textarea>
                            <a style="margin-left: 10px;cursor: pointer;color: #3994f7;" id="add_f_2"><fmt:message code="global.lang.add" /></a>
                            <a class="clearAll" style="color: #3994f7;"><fmt:message code="global.lang.empty" /></a>
                            <input type="hidden" name="viewDept" value="">
                            <input type="hidden" name="viewDeptName">
                        </div>
                    </div>
                    <div class="title_3">
                        <div class="title3_label">
                            <span class="title_s"><fmt:message code="sms.th.CirculatinRole" /></span></div>
                        <div class="select_put">
                            <textarea name="txt" id="text_3" value="" disabled="" userpriv=""></textarea>
                            <a style="margin-left: 10px;cursor: pointer;    color: #3994f7;" id="add_f_3"><fmt:message code="global.lang.add" /></a>
                            <a class="clearAll" style="    color: #3994f7;"><fmt:message code="global.lang.empty" /></a>
                            <input type="hidden" name="viewRole" value="">
                            <input type="hidden" name="viewRoleName">
                        </div>
                    </div>
                </div>

                <div class="form_group sex_r">
                    <label class="flowName"><fmt:message code="workflow.th.Ne" /></label>
                    <input type="radio" name="flowDoc" value="1" checked="checked">
                    <label class="sex_n"><fmt:message code="global.lang.yes" /></label>
                    <input type="radio" name="flowDoc" value="0">
                    <label class="sex_save"><fmt:message code="global.lang.no" /></label>
                </div>
                <div class="form_group sex_r">
                    <label class="flowName">开启正文</label>
                    <input type="radio" name="documentFlag" value="1" checked="checked">
                    <label class="sex_n"><fmt:message code="global.lang.yes" /></label>
                    <input type="radio" name="documentFlag" value="0">
                    <label class="sex_save"><fmt:message code="global.lang.no" /></label>
                </div>
                <div class="form_group sex_r">
                    <label class="flowName">正文版式文件格式</label>
                    <input type="radio" name="documentLayout" value="1" checked="checked">
                    <label class="sex_n">pdf</label>
                    <input type="radio" name="documentLayout" value="2">
                    <label class="sex_save">aip</label>
                </div>
                <div class="form_group sex_r">
                    <label class="flowName">是否允许选择文号类型</label>
                    <input type="radio" name="sysRuleYn" value="0" checked="checked">
                    <label class="sex_n">不允许</label>
                    <input type="radio" name="sysRuleYn" value="1">
                    <label class="sex_save">允许</label>
                </div>

                <div class="form_group sex_r">
                    <label class="flowName">允许选择经办人时自定义组不受经办权限限制</label>
                    <input type="radio" name="groupUserYn" value="0" checked="checked">
                    <label class="sex_n">不允许</label>
                    <input type="radio" name="groupUserYn" value="1">
                    <label class="sex_save">允许</label>
                </div>
                <%-- <div class="form_group sex_r">
                     <label class="flowName">正文word编辑插件</label>
                     <input type="radio" name="documentWordEditor" value="1" checked="checked">
                     <label class="sex_n">点聚WebOffice插件</label>
                     <input type="radio" name="documentWordEditor" value="2">
                     <label class="sex_save">软航 NTKO插件</label>
                 </div>--%>

                <%--<div class="form_group sex_r">--%>
                <%--<label class="flowName"><fmt:message code="workflow.th.Versioning" /></label>--%>
                <%--<input type="radio" name="isVersion" value="1" checked="checked"><label class="sex_n"><fmt:message code="global.lang.yes" /></label>--%>
                <%--<input type="radio" name="isVersion" value="0"><label class="sex_save"><fmt:message code="global.lang.no" /></label>--%>

                <%--</div>--%>

                <div class="form_group sex_r sex_r_f">
                    <label class="flowName"><fmt:message code="workflow.th.action" /></label>
                    <%--<input type="checkbox" name="flowAction" value="1"><label class="label_f"><fmt:message code="notice.title.notify" /></label>--%>
                    <%--<input type="checkbox" name="flowAction" value="2"><label class="label_f"><fmt:message code="workflow.th.Internalmail" /></label>--%>
                    <input type="checkbox" name="flowAction" value="3" style="display: none"><label class="label_f" style="display: none"><fmt:message code="workflow.th.Dump" /></label>
                    <input type="checkbox" name="flowAction" value="4"><label class="label_f placeFile"><fmt:message code="workflow.th.File" /></label>
                    <input type="checkbox" name="flowAction" value="5"><label class="label_f placeFile"><fmt:message code="global.lang.report" /></label>
                    <p class="set_form"><fmt:message code="workflow.th.Setupforms" /></p>

                </div>
                <div class="form_group sex_r sex_r_f" style="margin-top: 10px;">
                    <label class="flowName">新建选择</label>

                    <input type="checkbox" name="newType" value="0" checked><label class="label_f" >快速新建</label>
                    <input type="checkbox" name="newType" value="1" checked ><label class="label_f placeFile">新建向导</label>
                    <%--<p class="set_form"><fmt:message code="workflow.th.Setupforms" /></p>--%>

                </div>
            </div>






            <p class="define_p" style="margin-top: 50px;padding-bottom: 0px">高级属性</p>
            <div style="position: relative;height: 480px">
                <div class="con_form">
                    <div class="form_group">
                        <label for="reference" class="flowName"><fmt:message code="workflow.th.expression" /></label>
                        <input type="text" name="autoName" id="reference">
                    </div>

                    <div class="form_group">
                        <label for="counteer" class="flowName"><fmt:message code="workflow.th.counter" /></label>
                        <input type="text" name="autoNum" id="counteer">
                    </div>

                    <div class="form_group">
                        <label for="figure" class="flowName"><fmt:message code="workflow.th.digits" /></label>
                        <input type="text" name="autoLen" id="figure">
                    </div>

                    <div class="form_group">
                        <label for="update_n" class="flowName"><fmt:message code="workflow.th.change" /></label>
                        <select name="forcePreSet" id="update_n" class="depName" onchange="is_force($(this))">
                            <option value="1"><fmt:message code="wworkflow.th.modify" /></option>
                            <option value="0" selected="selected"><fmt:message code="workflow.th.nomodify" /></option>
                            <option value="2"><fmt:message code="workflow.th.prefixes" /></option>
                            <option value="3"><fmt:message code="workflow.th.suffixes" /></option>
                            <option value="4"><fmt:message code="workflow.th.prefixesandsuffixes" /></option>
                        </select>
                        <label class="checkbox" style="margin-left: 20px;margin-top: 5px;padding-left: 20px;position: relative;display: none" name="force" id="force">
                            <input type="checkbox" name="freePresetCheck" value="0" style="position: absolute;left: 0;top: 4px;"> 必须输入
                            <input type="hidden" name="freePreset" value="0">
                        </label>
                    </div>

                    <div class="form_group">
                        <label for="fileds" class="flowName">表单字段</label>
                        <select id="fileds" class="depName" name="formItem"></select>
                    </div>

                </div>


                <div class="conForm_r">
                    <p><fmt:message code="workflow.th.document" /></p>
                    <p><fmt:message code="workflow.th.specialtags" />:</p>
                    <div>
                        <span><fmt:message code="workflow.th.meansyear" /> </span>
                        <span style="margin-left: 62px;"><fmt:message code="workflow.th.month" /> </span>
                        <span style="margin-left: 55px;"><fmt:message code="workflow.th.day" /> </span>
                    </div>
                    <div style="margin-top: 5px;">
                        <span><fmt:message code="workflow.th.when" /></span>
                        <span style="margin-left: 62px;"><fmt:message code="workflow.th.points" /></span>
                        <span style="margin-left: 62px;"><fmt:message code="workflow.th.seconds" /></span>
                    </div>
                    <div style="margin-top: 5px;">
                        <span><fmt:message code="workflow.th.process-name" /></span>
                        <span style="margin-left: 40px;"><fmt:message code="workflow.th.username" /></span>
                        <span style="margin-left: 22px;"><fmt:message code="workflow.th.role" /></span>
                    </div>
                    <div style="margin-top: 5px;">
                        <span><fmt:message code="workflow.FS" /></span>
                        <span style="margin-left: 1px;"><fmt:message code="workflow.th.SD" /></span>
                    </div>
                    <div style="margin-top: 5px;">
                        <span><fmt:message code="workflow.th.LD" /></span>
                        <span style="margin-left: 36px;"><fmt:message code="workflow.th.RUN" /></span>
                    </div>
                    <div style="margin-top: 5px;">
                        <span><fmt:message code="workflow.th.N" /></span>
                    </div>
                    <div style="margin-top: 5px;">
                        <span><fmt:message code="workflow.th.NY" /></span>
                    </div>
                    <div style="margin-top: 5px;">
                        <span><fmt:message code="workflow.th.NM" /></span>
                    </div>
                    <div style="margin-top: 5px;">
                        <span>{FS字段名称FE}|[设计步骤序号]</span>
                    </div>
                    <div style="margin-top: 5px;">
                        <span><fmt:message code="workflow.th.exmaple" />，</span>
                    </div>
                    <div style="margin-top: 5px;">
                        <span><fmt:message code="workflow.th.automatically" />。</span>
                    </div>
                    <div style="margin-top: 5px;">
                        <span><fmt:message code="workflow.th.example" />，</span>
                    </div>
                    <div style="margin-top: 5px;">
                        <span><fmt:message code="workflow.th.BH" />。</span>
                    </div>
                    <div style="margin-top: 5px;">
                        <span><fmt:message code="workflow.th.the-expression" />，</span>
                    </div>
                    <div style="margin-top: 5px;">
                        <span><fmt:message code="workflow.zhangsan" />。</span>
                    </div>
                    <div style="margin-top: 5px;">
                        <span><fmt:message code="workflow.th.such" />：</span>
                    </div>
                    <div style="margin-top: 5px;">
                        <span><fmt:message code="workflow.th.leaveprocedure" />。</span>
                    </div>
                    <div style="margin-top: 5px;">
                        <span>例如，表达式为：{FS会议名称FE}|[2]，表示工作名称/文号会在流程转交至</span>
                    </div>
                    <div style="margin-top: 5px;">
                        <span>设计步骤2后点击转交时，获取表单中“会议名称”字段中的数据显示</span>
                    </div>
                </div>

            </div>


            <p class="define_p" style="margin-top: 50px;padding-bottom: 0px">默认正文模板</p>
            <div class="con_form" style="margin-bottom: 70px;">
                <div class="form_group">
                    <label for="templateId" class="flowName">模板选择</label>
                    <select id="templateId" class="depName" name="templateId">
                        <option value="0">请选择</option>
                    </select>
                </div>
            </div>


            <p class="define_p" style="margin-top: 50px;padding-bottom: 0px"><fmt:message code="workflow.th.Processdes" /></p>
            <div class="con_form" id="con_form">
                <div class="form_group clearfix">
                    <label for="reference" class="flowName" style="float: left"><fmt:message code="workflow.th.shuoming" /></label>
                    <%--<span class="notable" style="padding-right: 66px;width: 65%;display: inline-block;text-align: left;color: #000;overflow: hidden;--%>
                    <%--text-overflow:ellipsis;"><a style="width: 20%;                        display: inline-block;margin-bottom: 10px; vertical-align:bottom;margin-right: 10px;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;" href="" class="fileAA" title=""></a></span>--%>
                    <div class="notable" style="padding-right: 66px;width: 65%;display: inline-block;text-align: left;color: #000;overflow: hidden;
text-overflow:ellipsis;"></div>
                </div>
                <div class="form_group form_icon files" style="position: relative;margin-top: 10px;">
                    <label for="counteer" class="flowName"><fmt:message code="global.th.fileup" /></label>
                    <%--上传附件--%>
                    <%--<input type="file" name="file" multiple="multiple" onchange="uploadinputimg(this)" class="w-icon5" style="z-index: 10;  width: 116px;opacity: 0;
    position: absolute;top: 0px;
    left: 22%;filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0)">--%>
                    <input type="file" name="file" multiple="multiple" id="fileupload" data-url="/flow/fileUpload?module=workflow"  class="w-icon5" style="z-index: 10;  width: 116px;opacity: 0;
    position: absolute;top: 0px;
    left: 22%;filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0)">
                    <i class="icon_plus"></i><input type="button" readonly="readonly" value="<fmt:message code="global.th.fileup" />" class="addfile"
                                                    id="addfile" style="cursor: pointer;vertical-align: 10px;    position: absolute;
    left: 24%;">

                </div>
            </div>



            <div id="container" style="width: 96%;min-height: 300px;margin: 30px 20px 100px 20px" type="text/plain">




            </div>






        </div>
    </div>
</form>
<script>
    var TempArr = [];
    var TempIdArr = [];
    //附件上传
    fileuploadFn('#fileupload',$('.notable'));
    var specialdept = 1;
    function is_force(e){
        if(e.val() == 2||e.val() == 3||e.val() == 4){
            $('#force').show();
        }else{
            $('#force').hide();
        }
    }
    function Child(datas, opt_li, level, parentId) {
        for (var i = 0; i < datas.length; i++) {
            if (level == 0 && i == 0) continue;
            var String = "";
            var space = ""
            for (var j = 0; j < level; j++) {
                space += "├&nbsp;&nbsp;&nbsp;";
            }
            if (i == 0) {
                String = space + "┌";
            }
            if (i != 0) {
                String = space + "├";
            }
            if (i == datas.length - 1) {
                String = space + "└";
            }
            if (parentId == datas[i].sortId) {
                opt_li += '<option value="' + datas[i].sortId + '" selected="selected">' + String + datas[i].sortName + '</option>';
            } else {
                opt_li += '<option value="' + datas[i].sortId + '">' + String + datas[i].sortName + '</option>';
            }

            if (datas[i].childs != null) {
                opt_li = Child(datas[i].childs, opt_li, level + 1, parentId);
            }
        }

        return opt_li;
    }
    function inputhX(name,v,fn) {
        if(v==undefined||v==''){
            return
        }
        else {
            $('[name="'+name+'"]').val(v)
            if(fn!=undefined){
                fn($('[name="'+name+'"]'))
            }
        }
    }


    function selecthX(name,v) {
        if(v==undefined||v==''){
            return
        }
        else {
            if(name=="formId"){
                $('[name="'+name+'"]').find('option').each(function (i,n) {
                    if($(this).val()==v){
                        $('#makeupCo').val($(this).text().trim())
                        return false
                    }
                })
            }else{
                $('[name="'+name+'"]').find('option').each(function (i,n) {
                    if($(this).val()==v){
                        $(this).attr('selected','selected')
                        return false
                    }
                })
            }

        }
    }

    function radioHx(name,v,fn) {
        if(v==undefined){
            return
        }
        else {
            $('[name="'+name+'"]').each(function (i,n) {
                if($(this).val()==v){
                    $(this).attr('checked',true)
                    if(fn!=undefined){
                        fn($('[name="'+name+'"]'))
                    }
                    return false
                }
            })

        }
    }
    function checkboxhX(name,v) {
        if(v==undefined||v==''){
            return
        }
        else {
            if(v.indexOf(',')==-1){
                $('[name="'+name+'"]').each(function (i,n) {
                    if($(this).val()==v){
                        $(this).attr('checked',true)
                    }
                })
            }else {
                var arr=v.split(',');
                $('[name="'+name+'"]').each(function (i,n) {
                    for(var i=0;i<arr.length;i++){
                        if($(this).val()==arr[i]){
                            $(this).attr('checked',true)
                        }
                    }
                })

            }

        }
    }


    var getRueObj=$.GetRequest();
    var ue = UE.getEditor('container');


    if(parent.getResObj.type=='add'){
        $('.block_n').hide()
    }

    $.fn.deptSelect = function (args, timers) {
        var _this = $(this);
        $.ajax({
            url: "/department/getAlldept",
            type: 'get',
            data: {},
            dataType: 'json',
            success: function (obj) {
                var data = obj.obj;
                departmentData = digui(data, 0);
                var str = departmentChild(departmentData, '<option value="0">系统（仅由系统管理员管理）</option>', 0, -1);
                _this.html(str);
                if (_this.attr('pval') && (_this.attr('pval').indexOf('_') > -1)) {
                    var pval = _this.attr('pval').split('_');
                    _this.val(pval[0]);
                }
                if (args != undefined) {
                    args(_this);
                }
            },
            error: function () {
            }
        });
    };




    var index = layer.load();
    $.when($.ajax({
        url: '/workflow/flowclassify/flow',
        type: 'get',
        dataType: 'json',
        success: function (obj) {
            if (obj.flag) {
                var data = obj.datas;
                var opt_li;
                opt_li = Child(data, opt_li, 0, -1);
                $('#classfiy').html(opt_li);
            }
        },
        error: function(obj){
            layer.close(index);
            $('#uploadimgform').show();
        }
    })).done(function () {
        (function (fn) {
            $('#deptName').deptSelect(function () {
                $.ajax({
                    url: '/form/allformlist',
                    type: 'GET',
                    dataType: 'json',
                    success: function (data) {
                        if (data.flag) {
                            var data = data.datas;
                            var html = '';
                            for (var i = 0; i < data.length; i++) {
                                html += '<option value="" disabled>' + data[i].sortName + '</option>'

                                TempArr[i]=data[i].sortName
                                TempIdArr[i]=''
                                var form = data[i].form;
                                for (var j = 0; j < form.length; j++) {
                                    html += '<option value="' + form[j].formId + '" >&nbsp;&nbsp;&nbsp;' + form[j].formName + '</option>'
                                    TempIdArr[j+1]=form[j].formId
                                    TempArr[j+1]=form[j].formName
                                }
                            }
                        }
                        $('#typenum').html(html)
                        fn()

                    },
                    error: function(obj){
                        layer.close(index);
                        $('#uploadimgform').show();
                    }
                })
            })
        })(function () {
            if(getRueObj.flowId!=undefined) {
                $.ajax({
                    type: "GET",
                    url: "/flow/selectAllFlow",
                    dataType: "JSON",
                    data: {
                        flowId: getRueObj.flowId
                    },
                    success: function (data) {
                        if (data.flag) {

                            if (data.object.templateId) {
                                selecthX('templateId',data.object.templateId)
                            }
                            inputhX('flowName',data.object.flowName)
                            selecthX('flowSort',data.object.flowSort)
                            selecthX('flowType',data.object.flowType)
                            selecthX('formId',data.object.formId)
                            selecthX('freeOther',data.object.freeOther)
                            selecthX('deptId',data.object.deptId)
                            inputhX('flowNo',data.object.flowNo)
                            radioHx('viewPriv',data.object.viewPriv,function (me) {
                                if($('[name="viewPriv"]:checked').val()==1){
                                    $(me).parent().next().show()
                                }else {
                                    $(me).parent().next().hide()
                                }

                            });

                            radioHx('sysRuleYn',data.object.sysRuleYn)
                            //允许选择经办人时自定义组不受经办权限限制
                            radioHx('groupUserYn',data.object.groupUserYn)

                            if(data.object.newType!=undefined){
                                if(data.object.newType.indexOf('0')>-1){
                                    $('[name="newType"]').eq(0).prop('checked',true)
                                }else{
                                    $('[name="newType"]').eq(0).prop('checked',false)
                                }
                                if(data.object.newType.indexOf('1')>-1){
                                    $('[name="newType"]').eq(1).prop('checked',true)
                                }else{
                                    $('[name="newType"]').eq(1).prop('checked',false)
                                }
                            }
                            radioHx('flowDoc',data.object.flowDoc);



                            radioHx('isVersion',data.object.isVersion)
                            $('[name="isVersion"]').each(function (i,n) {
                                if(data.object.isVersion==undefined){
                                    return false
                                }else {
                                    if($(this).val()==data.object.isVersion){
                                        $(this).attr('checked',true)
                                        return false
                                    }
                                }

                            })




                            inputhX('viewUser',data.object.viewUser,function (me) {
                                $(me).prev().find('textarea').attr('user_id',$(me).val())
                                $(me).prev().find('textarea').val(data.object.viewUserName)
                            })
                            inputhX('viewDept',data.object.viewDept,function (me) {
                                $(me).siblings('textarea').attr('deptid',$(me).val())
                                $(me).siblings('textarea').val(data.object.viewDeptName)
                            })
                            inputhX('viewRole',data.object.viewRole,function (me) {
                                $(me).siblings('textarea').attr('userpriv',$(me).val())
                                $(me).siblings('textarea').val(data.object.viewRoleName)
                            })
                            checkboxhX('flowAction',data.object.flowAction)
                            inputhX('autoName',data.object.autoName)
                            inputhX('autoNum',data.object.autoNum)
                            inputhX('autoLen',data.object.autoLen)
                            selecthX('forcePreSet',data.object.forcePreSet)
                            if(data.object.forcePreSet == 2||data.object.forcePreSet == 3||data.object.forcePreSet == 4){
                                $('#force').show();
                            }
                            if(data.object.freePreset == 1){
                                $('[name=freePresetCheck]').attr('checked','1')
                            }
                            /*if(data.object.attachmentName!='') {
                                var arrOne=data.object.attachment;
                                var attachNameHtml='';
                                for(var i=0;i<arrOne.length;i++){
                                    attachNameHtml+='<div class="fujianOut"><a deUrl="'+arrOne[i].attUrl+'" attachId="'+arrOne[i].id+'" attachName="'+arrOne[i].name+'"  style="width: 20%;margin-bottom: 10px; vertical-align:bottom;margin-right: 10px;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;color: #54b6fe;" href="/download?'+arrOne[i].attUrl+'" class="fileAA fujian" title="'+arrOne[i].attachName+'" ><img class="img_" src="../img/enclosure.png">'+arrOne[i].attachName+'<span style="margin-left: 5px;">('+arrOne[i].size+')</span></a><img class="deImgs" style="margin-left:5px;cursor: pointer;" src="../img/file/icon_deletecha_03.png"/><input type="hidden" class="inHidden" value=""></div>'
                                }
                                $('.notable').append(attachNameHtml);
                            }*/
                            if(data.object.attachmentName!='') {
                                var datas = data.object.attachment;
                                var str = '';;
                                for (var i = 0; i < datas.length; i++) {
                                    str+='<div class="dech" deUrl="'+encodeURI(datas[i].attUrl)+'" style="display:block;"><a href="/download?'+encodeURI(datas[i].attUrl)+'"  class="ATTACH_a" style="color: #000;" NAME="'+datas[i].attachName+'*" href="javascript:;"><img style="margin-right:10px;" src="/img/attachment_icon.png"/>'+datas[i].attachName+'</a><img class="deImgs" style="margin-left:5px;cursor: pointer;" src="../img/file/icon_deletecha_03.png"/><input type="hidden" NAME="'+datas[i].attachName+'*"  class="inHidden" value="'+datas[i].aid+'@'+datas[i].ym+'_'+datas[i].attachId+',"></div>';
                                }
                                $('.notable').append(str);
                            }
                            $('[name="attachmentId"]').val(data.object.attachmentId)
                            $('[name="attachmentName"]').val(data.object.attachmentName)
                            $('[name="flowId"]').val(data.object.flowId)
                            $('[name="flowDesc"]').val(data.object.flowDesc)
                            ue.setContent(data.object.flowDesc)

                        }
                        layer.close(index);
                        $('#uploadimgform').show();
                        var str = '';
                        for(var i=0;i<data.obj1.length;i++){
                            str += '<option value="'+ i +'" selected="selected">'+ data.obj1[i] +'</option>'
                        }
                        $('select[name=formItem]').html(str);
                    },
                    error: function(obj){
                        layer.close(index);
                        $('#uploadimgform').show();
                    }
                });
            }else{
                layer.close(index);
                $('#uploadimgform').show();
            }
        })



    })
    //删除附件
    $(document).on('click','.deImgs',function(){
        /*var data=$(this).prev('.fujian').attr('deurl');
        var dome=$(this).parent('.fujianOut');*/
        var data=$(this).parents('.dech').attr('deUrl');
        var dome=$(this).parents('.dech');
        deleteChatment(data,dome);
    });
    function deleteChatment(data,element){

        layer.confirm('<fmt:message code="workflow.th.que" />？', {
            btn: ['<fmt:message code="global.lang.ok" />','<fmt:message code="depatement.th.quxiao" />'], //按钮
            title:"<fmt:message code="notice.th.DeleteAttachment" />"
        }, function(){
            //确定删除，调接口
            $.ajax({
                type:'get',
                url:'../delete',
                dataType:'json',
                data:data,
                success:function(res){

                    if(res.flag == true){
                        layer.msg('<fmt:message code="workflow.th.delsucess" />', { icon:6});
                        element.remove();
                    }else{
                        layer.msg('<fmt:message code="lang.th.deleSucess" />', { icon:6});
                    }
                }
            });

        }, function(){
            layer.closeAll();
        });
    }



    $('.keepmsg').on('click', function () {
        if($('#projectName').val()==''){
            alert('请输入流程名称！');
            return;
        }
        if($('#makeupCo').val()==''){
            alert('请选择表单！');
            return;
        }
        if($('#orderID').val()!=''){
            if($('#orderID').val()>=100000000){
                alert('流程排序号不得大于八位数字！');
                $('#orderID').val(99999999);
                return;
            }
        }
        var index = layer.load();
        if($('[name="viewPriv"]:checked').val()==0){
            $('#text_1').attr('user_id','')
            $('#text_1').val('')
            $('#text_2').attr('deptid','')
            $('#text_3').attr('userpriv','')
            $('#text_3').val('')
            $('#text_2').val('')
        }
        $('[name="viewUser"]').val($('#text_1').attr('user_id'))
        $('[name="viewDept"]').val($('#text_2').attr('deptid'))
        $('[name="viewRole"]').val($('#text_3').attr('userpriv'))
        $('[name="flowDesc"]').val(ue.getContent())
        if($('#update_n').val() == 2||$('#update_n').val() == 3||$('#update_n').val() == 4){
            if($('[name=freePresetCheck]').is(':checked')){
                $('[name=freePreset]').val('1')
            }else{
                $('[name=freePreset]').val('0')
            }
        }else{
            $('[name=freePreset]').val('0');
        }
        /* var attachId='';
         var attachName='';
         $('.fujian').each(function () {
             attachId+= $(this).eq(0).attr('attachId')
             attachName+= $(this).eq(0).attr('attachName')
         })
         $('[name="attachmentId"]').val(attachId)
         $('[name="attachmentName"]').val(attachName)*/

        var filearr=$('.notable .dech');
        var aId='';
        var uId='';
        for(var i=0;i<filearr.length;i++){
            aId+=$(filearr[i]).find('input').val();
            uId+=$(filearr[i]).find('a').attr('name');
        }
        $('[name="attachmentId"]').val(aId);
        $('[name="attachmentName"]').val(uId);

        if (getRueObj.flowId==undefined) {
            $('#uploadimgform').attr('action','/flow/newFlow');
            $('#uploadimgform').ajaxSubmit({
                type:'post',
                dataType:'html',
                success:function (json) {
                    var jsons=JSON.parse(json);
                    if(jsons.flag) {
                        $.layerMsg({content: '<fmt:message code="diary.th.modify" />！', icon: 1}, function () {
                            parent.parentUrl('/flowSetting/flowSettingMain?type=edit&flowId=' + jsons.object.flowId);
                        });
                    }else {
                        layer.close(index);
                        $.layerMsg({content: jsons.msg, icon: 2});
                    }
                },
                error:function(obj){
                    layer.close(index);
                }
            })
        } else {
            $('#uploadimgform').attr('action','/flow/updateFlow');
            $('[name="flowId"]').val(getRueObj.flowId)
            $('#uploadimgform').ajaxSubmit({
                type:'post',
                dataType:'html',
                success:function (json) {
                    var jsons=JSON.parse(json);
                    if(jsons.flag) {
                        $.layerMsg({content: '<fmt:message code="workflow.th.savedefineprocess" />！', icon: 1}, function () {
                            parent.parentUrl('/flowSetting/flowSettingMain?type=edit&flowId=' + getRueObj.flowId);
                        });
                    }else {
                        layer.close(index);
                        $.layerMsg({content: jsons.msg, icon: 2});
                    }
                },
                error:function(obj){
                    layer.close(index);
                }
            })
        }

    });

    $("#add_f_1").click(function () {
        user_id = 'text_1';
        $.popWindow("../common/selectUser");
    });
    $("#add_f_2").click(function () {
        dept_id = 'text_2';
        $.popWindow("../common/selectDept?allDept=1");
    })
    $("#add_f_3").click(function () {
        priv_id = 'text_3';
        $.popWindow("../common/selectPriv");
    })
    $('.radio_s').click(function () {
        if($(this).val()==1){
            $(".block_n").show();
        }else {
            $(".block_n").hide();

        }
    })
    $('.clearAll').click(function () {
        $(this).siblings('textarea').val('').attr({ 'user_id':'','username':'','userprivname':'','dataid':'','deptid':'','deptname':'','deptno':'','privid':'','userpriv':''});
    })

    // 获取可选择模板
    $.get('/template/queryTemplateByPrivs?type=office&categoryId=1&useFlag=false', function(res){
        if (res.flag) {
            if (res.obj.length > 0) {
                var str = ''
                res.obj.forEach(function(item){
                    str += '<option value="'+item.id+'">'+item.name+'</option>';
                });
                $('#templateId').append($(str));
            }
        }
    });
    $('#makeupCo').click(function () {
        bodyevent("#typenum","#makeupCo","#search-button");
    })
    function bodyevent(a, b, c) {
        $(a + " option").each(function(index, el) {
            TempArr[index] = $(this).text()
            TempIdArr[index] = $(this).attr('value')
        });
        $(document).bind('click',
            function(e) {
                var e = e || window.event;
                var elem = e.target || e.srcElement;
                while (elem) {
                    if (elem.id && (elem.id == a.replace('#', '') || elem.id == b.replace('#', '') || elem.id == c.replace('#', ''))) {
                        return
                    }
                    elem = elem.parentNode
                }
                $(a).css({
                    "display": "none",
                    "border-color": "#b8b8b8"
                });
                $(b).css({
                    "border-color": "#b8b8b8"
                });
                $(c + " span").removeClass("up")
            })
    };
    function changeF(this_, a, b, c) {
        if($(this_).find("option:selected").attr('value')!=''){
            $(this_).prevAll("input[id='" + b + "']").val($(this_).find("option:selected").text());
            $(a).css({
                "display": "none"
            });
            $(c + " span").removeClass("up")

            $("input[name='formId']").val($(this_).find("option:selected").val())

        }
    };
    function setfocus(this_, a, b, c) {
        $(a).css({
            "display": "",
            "border-color": "#38f"
        });
        $(b).css({
            "border-color": "#38f"
        });
        $(c + " span").addClass("up");
        var select = $(a);
        select.html("");
        for (var i = 0; i < TempArr.length; i++) {
            if(TempIdArr[i]!=''){
                var option = $('<option value="'+TempIdArr[i]+'" style="padding-left: 25px;"></option>').text(TempArr[i]);
            }else{
                var option = $('<option value="'+TempIdArr[i]+'"></option>').text(TempArr[i]);
            }
            select.append(option)
        }
    };
    function setinput(this_, a) {
        var select = $(a);
        select.html("");
        for (i = 0; i < TempArr.length; i++) {
            if (TempArr[i].indexOf(this_.value) >= 0) {
                if(TempIdArr[i]!=''){
                    var option = $('<option value="'+TempIdArr[i]+'" style="padding-left: 25px;"></option>').text(TempArr[i]);
                }else{
                    var option = $('<option value="'+TempIdArr[i]+'"></option>').text(TempArr[i]);
                }
                select.append(option)
            }
        }
    };
</script>
</body>
</html>
